import request from '@/utils/http.js'

const appkey = 'U2FsdGVkX19WSQ59Cg+Fj9jNZPxRC5y0xB1iV06BeNA='

// 根据id获取商品详情

export const getProDetail = (params) => {
	if(!params) {
		params = { appkey }
	} else {
		params['appkey'] = appkey
	}
	return request({
		method: 'GET',
		url: '/productDetail',
		params
	})
}

// 根据id获取商品收藏信息

export const findLike = (params) => {
	if(!params) {
		params = { appkey }
	} else {
		params['appkey'] = appkey
	}
	return request({
		method: 'GET',
		url: '/findlike',
		params
	})
}

/*
	根据id获取商品收藏信息 /like
	移除我的收藏  /notlike
	query: {
		appkey,
		tokenString,
		pid
	}
*/

export const saveLike = (status = false, data) => {
	if(!data) {
		data = { appkey }
	} else {
		data['appkey'] = appkey
	}
	return request({
		method: 'POST',
		url: status ? '/like' : '/notlike',
		data
	})
}

